﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TEC.Web.Component.ValidateCode;
using TongTongMall.Dependecy;
using TongTongMall.MallWeb.Application.Configuration;
using TongTongMall.MallWeb.Application.Configuration.Instance;

namespace TongTongMall.MallWeb.Application.Configuration
{
    public class ApplicationDefaultInstance : IApplicationInstance, ISingletonDependency
    {
        public static ApplicationDefaultInstance Instance { get { return SingletonInstance; } }

        private static readonly ApplicationDefaultInstance SingletonInstance = new ApplicationDefaultInstance();

        public ApiConfig ApiConfig
        {
            get
            {
                IocManager.Instance.RegisterIfNot<ApiConfig>(DependencyLifeStyle.Singleton);
                return IocManager.Instance.Resolve<ApiConfig>();
            }
        }

        private ValidateCodeManager _ValidateCodeManager;
        public ValidateCodeManager ValidateCodeManager
        {
            get
            {
                if (_ValidateCodeManager != null) return _ValidateCodeManager;
                var manager = new ValidateCodeManager
                {
                    Default = IocManager.Instance.Resolve<DefaultApiValidateImage>()
                };
                manager.ValidateCodeDic["login"] = manager.Default;
                _ValidateCodeManager = manager;
                return _ValidateCodeManager;
            }
        }
    }
}
